home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / ActView / ActiveViewer.jar / com / simeda / ActiveViewer / vncCanvas.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-12-12  |  11.9 KB  |  605 lines

  1. package com.simeda.ActiveViewer;
  2.  
  3. import java.io.IOException;
  4. import java.util.Vector;
  5. import javax.microedition.lcdui.Canvas;
  6. import javax.microedition.lcdui.Command;
  7. import javax.microedition.lcdui.Displayable;
  8. import javax.microedition.lcdui.Font;
  9. import javax.microedition.lcdui.Graphics;
  10. import javax.microedition.lcdui.Image;
  11.  
  12. class vncCanvas extends Canvas {
  13.    rfbProto rfb = null;
  14.    Image paintImage;
  15.    Graphics pig;
  16.    Graphics pig2;
  17.    boolean needToResetClip;
  18.    boolean isRunning = true;
  19.    Command disconnectCommand = null;
  20.    Command textCommand = null;
  21.    Command cursorCommand = null;
  22.    Command imageCommand = null;
  23.    Command arrowCommand = null;
  24.    Command numericCommand = null;
  25.    Command textAreaCommand = null;
  26.    Command specialCharsCommand = null;
  27.    TextArea textArea;
  28.    SpecialChars specialCharsList;
  29.    boolean isCtrlPressed;
  30.    boolean isAltPressed;
  31.    boolean isMetaPressed;
  32.    Command pressCtrl;
  33.    Command pressAlt;
  34.    Command pressMeta;
  35.    Command releaseCtrl;
  36.    Command releaseAlt;
  37.    Command releaseMeta;
  38.    VNCController parent = null;
  39.    private Vector _status = new Vector();
  40.    KeyReader keyReader;
  41.    public static final int CURSOR = 1;
  42.    public static final int TEXT = 2;
  43.    public static final int IMAGE = 3;
  44.    public static final int ARROW = 4;
  45.    public static final int NUMERIC = 5;
  46.    public static final int TEXTAREA = 6;
  47.    int keyMode = 1;
  48.    int deltaX = 0;
  49.    int deltaY = 0;
  50.    boolean incremental;
  51.    public char currentLetter = '\uffff';
  52.    int cursorX;
  53.    int cursorY;
  54.    int cursorButton;
  55.  
  56.    public int toRGB(int var1) {
  57.       int var2 = (var1 & 7) * 255 / 7;
  58.       int var3 = (var1 >> 3 & 7) * 255 / 7;
  59.       int var4 = (var1 >> 6 & 3) * 255 / 3;
  60.       return (var2 << 16) + (var3 << 8) + var4;
  61.    }
  62.  
  63.    public void status(String var1) {
  64.       this._status.addElement(var1);
  65.       ((Canvas)this).repaint();
  66.       ((Canvas)this).serviceRepaints();
  67.    }
  68.  
  69.    vncCanvas(VNCController var1) throws IOException {
  70.       this.parent = var1;
  71.       this.disconnectCommand = new Command("Disconnect", 4, 1);
  72.       this.cursorCommand = new Command("Move cursor", 4, 1);
  73.       this.imageCommand = new Command("Move image", 4, 1);
  74.       this.arrowCommand = new Command("Send arrows", 4, 1);
  75.       this.textCommand = new Command("Character keypad", 4, 1);
  76.       this.numericCommand = new Command("Numeric keypad", 4, 1);
  77.       this.textAreaCommand = new Command("Show text area", 4, 1);
  78.       this.specialCharsCommand = new Command("Special characters", 4, 1);
  79.       this.pressCtrl = new Command("Press CTRL", 4, 1);
  80.       this.pressAlt = new Command("Press ALT", 4, 2);
  81.       this.pressMeta = new Command("Press META", 4, 3);
  82.       this.releaseCtrl = new Command("Release CTRL", 4, 1);
  83.       this.releaseAlt = new Command("Release ALT", 4, 2);
  84.       this.releaseMeta = new Command("Release META", 4, 3);
  85.    }
  86.  
  87.    public void doInit(rfbProto var1) throws IOException {
  88.       System.out.println("Doing init");
  89.       this.rfb = var1;
  90.       this.textArea = new TextArea(this);
  91.       this.specialCharsList = new SpecialChars(this);
  92.       this.keyReader = new KeyReader(var1, this);
  93.       this.rfb.writeSetPixelFormat(8, 8, false, true, 7, 7, 3, 0, 3, 6);
  94.       this.paintImage = Image.createImage(((Canvas)this).getWidth(), ((Canvas)this).getHeight());
  95.       this.pig = this.paintImage.getGraphics();
  96.       System.out.println("HAS POINTER EVENTS " + ((Canvas)this).hasPointerEvents());
  97.       System.out.println("HAS POINTER MOTION EVENTS " + ((Canvas)this).hasPointerMotionEvents());
  98.       System.out.println("HAS REPEAT EVENTS " + ((Canvas)this).hasRepeatEvents());
  99.    }
  100.  
  101.    public void doCommands() {
  102.       ((Displayable)this).removeCommand(this.disconnectCommand);
  103.       ((Displayable)this).removeCommand(this.cursorCommand);
  104.       ((Displayable)this).removeCommand(this.imageCommand);
  105.       ((Displayable)this).removeCommand(this.arrowCommand);
  106.       ((Displayable)this).removeCommand(this.numericCommand);
  107.       ((Displayable)this).removeCommand(this.textCommand);
  108.       ((Displayable)this).removeCommand(this.textAreaCommand);
  109.       ((Displayable)this).removeCommand(this.specialCharsCommand);
  110.       ((Displayable)this).removeCommand(this.releaseCtrl);
  111.       ((Displayable)this).removeCommand(this.pressCtrl);
  112.       ((Displayable)this).removeCommand(this.releaseAlt);
  113.       ((Displayable)this).removeCommand(this.pressAlt);
  114.       ((Displayable)this).removeCommand(this.releaseMeta);
  115.       ((Displayable)this).removeCommand(this.pressMeta);
  116.       ((Displayable)this).addCommand(this.disconnectCommand);
  117.       ((Displayable)this).addCommand(this.cursorCommand);
  118.       ((Displayable)this).addCommand(this.imageCommand);
  119.       ((Displayable)this).addCommand(this.arrowCommand);
  120.       ((Displayable)this).addCommand(this.numericCommand);
  121.       ((Displayable)this).addCommand(this.textCommand);
  122.       ((Displayable)this).addCommand(this.textAreaCommand);
  123.       ((Displayable)this).addCommand(this.specialCharsCommand);
  124.       if (this.isCtrlPressed) {
  125.          ((Displayable)this).addCommand(this.releaseCtrl);
  126.       } else {
  127.          ((Displayable)this).addCommand(this.pressCtrl);
  128.       }
  129.  
  130.       if (this.isAltPressed) {
  131.          ((Displayable)this).addCommand(this.releaseAlt);
  132.       } else {
  133.          ((Displayable)this).addCommand(this.pressAlt);
  134.       }
  135.  
  136.       if (this.isMetaPressed) {
  137.          ((Displayable)this).addCommand(this.releaseMeta);
  138.       } else {
  139.          ((Displayable)this).addCommand(this.pressMeta);
  140.       }
  141.  
  142.    }
  143.  
  144.    public void this_commandPerformed(Command var1, Displayable var2) {
  145.       if (var1 == this.disconnectCommand) {
  146.          this.isRunning = false;
  147.          this.rfb.close();
  148.       } else if (var1 == this.textCommand) {
  149.          this.keyMode = 2;
  150.       } else if (var1 == this.cursorCommand) {
  151.          this.keyMode = 1;
  152.       } else if (var1 == this.imageCommand) {
  153.          this.keyMode = 3;
  154.       } else if (var1 == this.numericCommand) {
  155.          this.keyMode = 5;
  156.       } else if (var1 == this.arrowCommand) {
  157.          this.keyMode = 4;
  158.       } else if (var1 == this.textAreaCommand) {
  159.          this.parent.display.setCurrent(this.textArea);
  160.       } else if (var1 == this.specialCharsCommand) {
  161.          this.parent.display.setCurrent(this.specialCharsList);
  162.       } else if (var1 == this.pressCtrl) {
  163.          this.isCtrlPressed = true;
  164.          this.doCommands();
  165.  
  166.          try {
  167.             this.rfb.writeKeyEvent(65507, true);
  168.          } catch (IOException var9) {
  169.          }
  170.       } else if (var1 == this.pressAlt) {
  171.          this.isAltPressed = true;
  172.          this.doCommands();
  173.  
  174.          try {
  175.             this.rfb.writeKeyEvent(65513, true);
  176.          } catch (IOException var8) {
  177.          }
  178.       } else if (var1 == this.pressMeta) {
  179.          this.isMetaPressed = true;
  180.          this.doCommands();
  181.  
  182.          try {
  183.             this.rfb.writeKeyEvent(65511, true);
  184.          } catch (IOException var7) {
  185.          }
  186.       } else if (var1 == this.releaseCtrl) {
  187.          this.isCtrlPressed = false;
  188.          this.doCommands();
  189.  
  190.          try {
  191.             this.rfb.writeKeyEvent(65507, false);
  192.          } catch (IOException var6) {
  193.          }
  194.       } else if (var1 == this.releaseAlt) {
  195.          this.isAltPressed = false;
  196.          this.doCommands();
  197.  
  198.          try {
  199.             this.rfb.writeKeyEvent(65513, false);
  200.          } catch (IOException var5) {
  201.          }
  202.       } else if (var1 == this.releaseMeta) {
  203.          this.isMetaPressed = false;
  204.          this.doCommands();
  205.  
  206.          try {
  207.             this.rfb.writeKeyEvent(65511, false);
  208.          } catch (IOException var4) {
  209.          }
  210.       }
  211.  
  212.    }
  213.  
  214.    public void paint(Graphics var1) {
  215.       var1.setColor(16777215);
  216.       var1.fillRect(0, 0, ((Canvas)this).getWidth(), ((Canvas)this).getHeight());
  217.       if (this.paintImage == null) {
  218.          var1.setColor(0);
  219.          int var2 = var1.getFont().getHeight();
  220.  
  221.          for(int var3 = 0; var3 < this._status.size(); ++var3) {
  222.             var1.drawString((String)this._status.elementAt(var3), 0, var3 * var2, 20);
  223.          }
  224.       } else {
  225.          try {
  226.             var1.drawImage(this.paintImage, 0, 0, 20);
  227.             if (this.currentLetter != '\uffff') {
  228.                var1.setColor(16777215);
  229.                var1.fillRect(((Canvas)this).getWidth() - 21, ((Canvas)this).getHeight() - 21, 20, 20);
  230.                var1.setColor(0);
  231.                var1.drawRect(((Canvas)this).getWidth() - 21, ((Canvas)this).getHeight() - 21, 20, 20);
  232.                Font var5 = Font.getFont(32, 1, 16);
  233.                var1.setFont(var5);
  234.                var1.setColor(16711680);
  235.                var1.drawChar(this.currentLetter, ((Canvas)this).getWidth() - 20 + (20 - var5.charWidth(this.currentLetter)) / 2, ((Canvas)this).getHeight() - 20 + (20 - var5.getHeight()) / 2, 20);
  236.             }
  237.          } catch (Exception var4) {
  238.          }
  239.       }
  240.  
  241.       var1.setColor(16711680);
  242.       var1.fillRect(this.cursorX, this.cursorY, 3, 3);
  243.    }
  244.  
  245.    public void processNormalProtocol() throws IOException {
  246.       this.isRunning = true;
  247.       ((Displayable)this).setCommandListener(new 1(this));
  248.       this.doCommands();
  249.       System.out.println("Sending request");
  250.       this.incremental = false;
  251.       this.rfb.writeFramebufferUpdateRequest(this.deltaX, this.deltaY, ((Canvas)this).getWidth(), ((Canvas)this).getHeight(), this.incremental);
  252.       this.needToResetClip = false;
  253.  
  254.       while(this.isRunning) {
  255.          int var1 = this.rfb.readServerMessageType();
  256.          switch (var1) {
  257.             case 0:
  258.                this.rfb.readFramebufferUpdate();
  259.                int var2 = 0;
  260.  
  261.                for(; var2 < this.rfb.updateNRects; ++var2) {
  262.                   this.rfb.readFramebufferUpdateRectHdr();
  263.                   if (this.needToResetClip && this.rfb.updateRectEncoding != 0) {
  264.                      this.pig.setClip(0, 0, this.rfb.framebufferWidth, this.rfb.framebufferHeight);
  265.                      this.needToResetClip = false;
  266.                   }
  267.  
  268.                   switch (this.rfb.updateRectEncoding) {
  269.                      case 0:
  270.                         this.drawRawRect(this.rfb.updateRectX, this.rfb.updateRectY, this.rfb.updateRectW, this.rfb.updateRectH);
  271.                         break;
  272.                      case 1:
  273.                      case 3:
  274.                      default:
  275.                         throw new IOException("Unknown RFB rectangle encoding " + this.rfb.updateRectEncoding);
  276.                      case 2:
  277.                         int var19 = this.rfb.is.readInt();
  278.                         int var21 = this.rfb.is.read();
  279.                         this.pig.translate(this.rfb.updateRectX, this.rfb.updateRectY);
  280.                         this.pig.setColor(this.toRGB(var21));
  281.                         this.pig.fillRect(0, 0, this.rfb.updateRectW, this.rfb.updateRectH);
  282.  
  283.                         for(int var37 = 0; var37 < var19; ++var37) {
  284.                            int var24 = this.rfb.is.read();
  285.                            int var27 = this.rfb.is.readUnsignedShort();
  286.                            int var30 = this.rfb.is.readUnsignedShort();
  287.                            int var33 = this.rfb.is.readUnsignedShort();
  288.                            int var35 = this.rfb.is.readUnsignedShort();
  289.                            this.pig.setColor(this.toRGB(var24));
  290.                            this.pig.fillRect(var27, var30, var33, var35);
  291.                         }
  292.  
  293.                         this.pig.translate(-this.rfb.updateRectX, -this.rfb.updateRectY);
  294.                         break;
  295.                      case 4:
  296.                         int var18 = this.rfb.is.readInt();
  297.                         int var20 = this.rfb.is.read();
  298.                         this.pig.translate(this.rfb.updateRectX, this.rfb.updateRectY);
  299.                         this.pig.setColor(this.toRGB(var20));
  300.                         this.pig.fillRect(0, 0, this.rfb.updateRectW, this.rfb.updateRectH);
  301.  
  302.                         for(int var36 = 0; var36 < var18; ++var36) {
  303.                            int var23 = this.rfb.is.read();
  304.                            int var26 = this.rfb.is.read();
  305.                            int var29 = this.rfb.is.read();
  306.                            int var32 = this.rfb.is.read();
  307.                            int var34 = this.rfb.is.read();
  308.                            this.pig.setColor(this.toRGB(var23));
  309.                            this.pig.fillRect(var26, var29, var32, var34);
  310.                         }
  311.  
  312.                         this.pig.translate(-this.rfb.updateRectX, -this.rfb.updateRectY);
  313.                         break;
  314.                      case 5:
  315.                         int var3 = 0;
  316.                         int var4 = 0;
  317.  
  318.                         for(int var9 = this.rfb.updateRectY; var9 < this.rfb.updateRectY + this.rfb.updateRectH; var9 += 16) {
  319.                            for(int var10 = this.rfb.updateRectX; var10 < this.rfb.updateRectX + this.rfb.updateRectW; var10 += 16) {
  320.                               int var11 = 16;
  321.                               int var12 = 16;
  322.                               if (this.rfb.updateRectX + this.rfb.updateRectW - var10 < 16) {
  323.                                  var11 = this.rfb.updateRectX + this.rfb.updateRectW - var10;
  324.                               }
  325.  
  326.                               if (this.rfb.updateRectY + this.rfb.updateRectH - var9 < 16) {
  327.                                  var12 = this.rfb.updateRectY + this.rfb.updateRectH - var9;
  328.                               }
  329.  
  330.                               int var13 = this.rfb.is.read();
  331.                               if ((var13 & 1) != 0) {
  332.                                  this.drawRawRect(var10, var9, var11, var12);
  333.                               } else {
  334.                                  if (this.needToResetClip) {
  335.                                     this.pig.setClip(0, 0, ((Canvas)this).getWidth(), ((Canvas)this).getHeight());
  336.                                     this.needToResetClip = false;
  337.                                  }
  338.  
  339.                                  if ((var13 & 2) != 0) {
  340.                                     var3 = this.rfb.is.read();
  341.                                  }
  342.  
  343.                                  this.pig.setColor(this.toRGB(var3));
  344.                                  this.pig.fillRect(var10, var9, var11, var12);
  345.                                  if ((var13 & 4) != 0) {
  346.                                     var4 = this.rfb.is.read();
  347.                                  }
  348.  
  349.                                  if ((var13 & 8) != 0) {
  350.                                     int var14 = this.rfb.is.read();
  351.                                     this.pig.translate(var10, var9);
  352.                                     if ((var13 & 16) != 0) {
  353.                                        for(int var15 = 0; var15 < var14; ++var15) {
  354.                                           var4 = this.rfb.is.read();
  355.                                           int var16 = this.rfb.is.read();
  356.                                           int var17 = this.rfb.is.read();
  357.                                           int var5 = var16 >> 4;
  358.                                           int var6 = var16 & 15;
  359.                                           int var7 = (var17 >> 4) + 1;
  360.                                           int var8 = (var17 & 15) + 1;
  361.                                           this.pig.setColor(this.toRGB(var4));
  362.                                           this.pig.fillRect(var5, var6, var7, var8);
  363.                                        }
  364.                                     } else {
  365.                                        this.pig.setColor(this.toRGB(var4));
  366.  
  367.                                        for(int var38 = 0; var38 < var14; ++var38) {
  368.                                           int var39 = this.rfb.is.read();
  369.                                           int var40 = this.rfb.is.read();
  370.                                           int var22 = var39 >> 4;
  371.                                           int var25 = var39 & 15;
  372.                                           int var28 = (var40 >> 4) + 1;
  373.                                           int var31 = (var40 & 15) + 1;
  374.                                           this.pig.fillRect(var22, var25, var28, var31);
  375.                                        }
  376.                                     }
  377.  
  378.                                     this.pig.translate(-var10, -var9);
  379.                                  }
  380.                               }
  381.                            }
  382.                         }
  383.                   }
  384.                }
  385.  
  386.                this.rfb.writeFramebufferUpdateRequest(this.deltaX, this.deltaY, ((Canvas)this).getWidth(), ((Canvas)this).getHeight(), this.incremental);
  387.                this.incremental = true;
  388.                break;
  389.             case 1:
  390.                throw new IOException("Can't handle SetColourMapEntries message");
  391.             case 2:
  392.                System.out.print('\u0007');
  393.                break;
  394.             default:
  395.                throw new IOException("Unknown RFB message type " + var1);
  396.          }
  397.  
  398.          ((Canvas)this).repaint();
  399.          ((Canvas)this).serviceRepaints();
  400.       }
  401.  
  402.    }
  403.  
  404.    void drawRawRect(int var1, int var2, int var3, int var4) throws IOException {
  405.       for(int var5 = var2; var5 < var2 + var4; ++var5) {
  406.          for(int var6 = var1; var6 < var1 + var3; ++var6) {
  407.             int var7 = this.rfb.is.read();
  408.             this.pig.setColor(this.toRGB(var7));
  409.             this.pig.fillRect(var6, var5, 1, 1);
  410.          }
  411.       }
  412.  
  413.    }
  414.  
  415.    public void pointerPressed(int var1, int var2) {
  416.       System.out.println("Got pointer press");
  417.       if (this.keyMode == 1) {
  418.          this.cursorX = var1;
  419.          this.cursorY = var2;
  420.          this.cursorButton = 1;
  421.          this.updateCursor();
  422.       } else if (this.keyMode == 3) {
  423.          this.pig.translate(this.deltaX, this.deltaY);
  424.          if (var1 > 20 && var1 < ((Canvas)this).getWidth() - 20 && var2 < 20) {
  425.             if (this.deltaY > ((Canvas)this).getHeight()) {
  426.                this.deltaY -= ((Canvas)this).getHeight();
  427.             } else {
  428.                this.deltaY = 0;
  429.             }
  430.          }
  431.  
  432.          if (var1 > 20 && var1 < ((Canvas)this).getWidth() - 20 & var2 > ((Canvas)this).getHeight() - 20) {
  433.             if (this.deltaY < this.rfb.framebufferHeight - 2 * ((Canvas)this).getHeight()) {
  434.                this.deltaY += ((Canvas)this).getHeight();
  435.             } else {
  436.                this.deltaY = this.rfb.framebufferHeight - ((Canvas)this).getHeight();
  437.             }
  438.          }
  439.  
  440.          if (var1 < 20 && var2 > 20 && var2 < ((Canvas)this).getHeight() - 20) {
  441.             if (this.deltaX > ((Canvas)this).getWidth()) {
  442.                this.deltaX -= ((Canvas)this).getWidth();
  443.             } else {
  444.                this.deltaX = 0;
  445.             }
  446.          }
  447.  
  448.          if (var1 > ((Canvas)this).getWidth() - 20 && var2 > 20 && var2 < ((Canvas)this).getHeight() - 20) {
  449.             if (this.deltaX < this.rfb.framebufferWidth - 2 * ((Canvas)this).getWidth()) {
  450.                this.deltaX += ((Canvas)this).getWidth();
  451.             } else {
  452.                this.deltaX = this.rfb.framebufferWidth - ((Canvas)this).getWidth();
  453.             }
  454.          }
  455.  
  456.          this.pig.translate(-this.deltaX, -this.deltaY);
  457.          this.incremental = false;
  458.  
  459.          try {
  460.             this.rfb.writeFramebufferUpdateRequest(this.deltaX, this.deltaY, ((Canvas)this).getWidth(), ((Canvas)this).getHeight(), this.incremental);
  461.          } catch (Exception var4) {
  462.             ((Throwable)var4).printStackTrace();
  463.          }
  464.  
  465.          ((Canvas)this).repaint();
  466.       }
  467.  
  468.    }
  469.  
  470.    public void keyPressed(int var1) {
  471.       if (this.keyMode == 1) {
  472.          int var2 = ((Canvas)this).getGameAction(var1);
  473.          if (var2 == 1 && this.cursorY > 0) {
  474.             --this.cursorY;
  475.          } else if (var2 == 6 && this.cursorY < ((Canvas)this).getHeight()) {
  476.             ++this.cursorY;
  477.          } else if (var2 == 2 && this.cursorX > 0) {
  478.             --this.cursorX;
  479.          } else if (var2 == 5 && this.cursorX < ((Canvas)this).getWidth()) {
  480.             ++this.cursorX;
  481.          } else if (var2 == 8) {
  482.             this.cursorButton = 1;
  483.          }
  484.  
  485.          this.updateCursor();
  486.          this.cursorButton = 0;
  487.       } else if (this.keyMode == 5) {
  488.          this.keyReader.pushNumericKey(var1);
  489.       } else if (this.keyMode == 2) {
  490.          if (var1 == 35) {
  491.             this.keyReader.toggleCaps();
  492.             return;
  493.          }
  494.  
  495.          if (var1 == 42) {
  496.             var1 = 65293;
  497.  
  498.             try {
  499.                this.rfb.writeKeyEvent(var1, true);
  500.             } catch (IOException var5) {
  501.                ((Throwable)var5).printStackTrace();
  502.             }
  503.  
  504.             return;
  505.          }
  506.  
  507.          this.keyReader.pushKey(var1);
  508.       } else if (this.keyMode == 3) {
  509.          this.pig.translate(this.deltaX, this.deltaY);
  510.          int var9 = ((Canvas)this).getGameAction(var1);
  511.          if (var9 == 1) {
  512.             if (this.deltaY > ((Canvas)this).getHeight()) {
  513.                this.deltaY -= ((Canvas)this).getHeight();
  514.             } else {
  515.                this.deltaY = 0;
  516.             }
  517.          }
  518.  
  519.          if (var9 == 6) {
  520.             if (this.deltaY < this.rfb.framebufferHeight - 2 * ((Canvas)this).getHeight()) {
  521.                this.deltaY += ((Canvas)this).getHeight();
  522.             } else {
  523.                this.deltaY = this.rfb.framebufferHeight - ((Canvas)this).getHeight();
  524.             }
  525.          }
  526.  
  527.          if (var9 == 2) {
  528.             if (this.deltaX > ((Canvas)this).getWidth()) {
  529.                this.deltaX -= ((Canvas)this).getWidth();
  530.             } else {
  531.                this.deltaX = 0;
  532.             }
  533.          }
  534.  
  535.          if (var9 == 5) {
  536.             if (this.deltaX < this.rfb.framebufferWidth - 2 * ((Canvas)this).getWidth()) {
  537.                this.deltaX += ((Canvas)this).getWidth();
  538.             } else {
  539.                this.deltaX = this.rfb.framebufferWidth - ((Canvas)this).getWidth();
  540.             }
  541.          }
  542.  
  543.          this.pig.translate(-this.deltaX, -this.deltaY);
  544.          this.incremental = false;
  545.  
  546.          try {
  547.             this.rfb.writeFramebufferUpdateRequest(this.deltaX, this.deltaY, ((Canvas)this).getWidth(), ((Canvas)this).getHeight(), this.incremental);
  548.          } catch (Exception var7) {
  549.             ((Throwable)var7).printStackTrace();
  550.          }
  551.  
  552.          ((Canvas)this).repaint();
  553.       } else if (this.keyMode == 4) {
  554.          int var10 = ((Canvas)this).getGameAction(var1);
  555.          char var3 = 0;
  556.          switch (var10) {
  557.             case 1:
  558.                var3 = '∩╜Æ';
  559.                break;
  560.             case 2:
  561.                var3 = '∩╜æ';
  562.             case 3:
  563.             case 4:
  564.             case 7:
  565.             default:
  566.                break;
  567.             case 5:
  568.                var3 = '∩╜ô';
  569.                break;
  570.             case 6:
  571.                var3 = '∩╜ö';
  572.                break;
  573.             case 8:
  574.                var3 = '∩╝ì';
  575.          }
  576.  
  577.          try {
  578.             this.rfb.writeKeyEvent(var3, true);
  579.          } catch (IOException var6) {
  580.             ((Throwable)var6).printStackTrace();
  581.             return;
  582.          }
  583.       }
  584.  
  585.    }
  586.  
  587.    public void keyRepeated(int var1) {
  588.       this.keyPressed(var1);
  589.    }
  590.  
  591.    public void updateCursor() {
  592.       ((Canvas)this).repaint();
  593.  
  594.       try {
  595.          this.rfb.writePointerEvent(this.cursorX + this.deltaX, this.cursorY + this.deltaY, this.cursorButton);
  596.          if (this.cursorButton != 0) {
  597.             this.rfb.writePointerEvent(this.cursorX + this.deltaX, this.cursorY + this.deltaY, 0);
  598.          }
  599.       } catch (IOException var2) {
  600.          ((Throwable)var2).printStackTrace();
  601.       }
  602.  
  603.    }
  604. }
  605.